home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / apple_gi.swf / scripts / frame_46 / DoAction.as < prev   
Text File  |  2013-04-24  |  15KB  |  531 lines

  1. function viewNumber(meter, num)
  2. {
  3.    var _loc4_ = String(num);
  4.    meter.gotoAndStop(_loc4_.length);
  5.    var _loc1_ = 0;
  6.    var _loc3_ = _loc4_.length - 1;
  7.    while(_loc3_ >= 0)
  8.    {
  9.       meter["n" + _loc1_].gotoAndStop(Number(_loc4_.charAt(_loc3_)) + 1);
  10.       meter["n" + _loc1_]._visible = true;
  11.       _loc1_ = _loc1_ + 1;
  12.       _loc3_ = _loc3_ - 1;
  13.    }
  14.    while(meter["n" + _loc1_] != undefined)
  15.    {
  16.       meter["n" + _loc1_].gotoAndStop(1);
  17.       meter["n" + _loc1_]._visible = false;
  18.       _loc1_ = _loc1_ + 1;
  19.    }
  20. }
  21. function goTitle()
  22. {
  23.    _quality = "BEST";
  24.    gotoAndStop("first");
  25.    GAMESTATE = "TITLE";
  26. }
  27. function goHelp()
  28. {
  29.    gotoAndStop("help");
  30.    GAMESTATE = "HELP";
  31. }
  32. function showRanking(arg)
  33. {
  34.    dataMode = arg;
  35.    gotoAndStop("ranking");
  36.    GAMESTATE = "RANKING";
  37.    if(arg == 2)
  38.    {
  39.       _root.controll.removeMovieClip();
  40.       _root.controll2.removeMovieClip();
  41.    }
  42. }
  43. function startGame()
  44. {
  45.    pauseMC.removeMovieClip();
  46.    _quality = "MIDIUM";
  47.    gotoAndStop("game");
  48.    initialize();
  49.    controll.swapDepths(1000);
  50.    controll2.swapDepths(999);
  51.    efx.swapDepths(1001);
  52.    efx_extra.swapDepths(1002);
  53.    efx_combo.swapDepths(1003);
  54.    pauseMC.swapDepths(10000);
  55. }
  56. function initialize()
  57. {
  58.    isPause = false;
  59.    pauseMC._visible = false;
  60.    controll2.avt1.gotoAndStop(1);
  61.    controll2.avt2.gotoAndStop(1);
  62.    controll2.avt3.gotoAndStop(1);
  63.    controll2.avt4.gotoAndStop(1);
  64.    bgm.stop();
  65.    bgm.attachSound("mainbgm");
  66.    bgm.start(0,999);
  67.    alertmc.gotoAndStop(1);
  68.    life = defaultLife;
  69.    controll.groove.gage._x = controll.groove.gage._width / 100 * life - controll.groove.gage._width;
  70.    score = 0;
  71.    combo = 0;
  72.    pspeed = 10;
  73.    receivedPresent = -1;
  74.    level = 1;
  75.    speed = 8;
  76.    createdPresent = 0;
  77.    depth = 0;
  78.    var _loc1_ = 0;
  79.    while(_loc1_ < 5)
  80.    {
  81.       catchedPresent.shift();
  82.       _loc1_ = _loc1_ + 1;
  83.    }
  84.    onEnterFrame = loopFrame;
  85.    GAMESTATE = "GAME";
  86.    PLAYERSTATE = "NORMAL";
  87.    startTime = getTimer();
  88. }
  89. function finalize()
  90. {
  91.    controll2.avt1.gotoAndStop(3);
  92.    controll2.avt2.gotoAndStop(3);
  93.    controll2.avt3.gotoAndStop(3);
  94.    controll2.avt4.gotoAndStop(3);
  95.    controll2.avt1.avt_mc.stop();
  96.    controll2.avt2.avt_mc.stop();
  97.    controll2.avt3.avt_mc.stop();
  98.    controll2.avt4.avt_mc.stop();
  99.    bgm.stop();
  100.    catchMiss(6);
  101.    alertmc.gotoAndStop(2);
  102.    onEnterFrame = null;
  103.    GAMESTATE = "GAMEOVER";
  104. }
  105. function returnPresent(who, where, presentType)
  106. {
  107.    var _loc4_ = false;
  108.    var _loc5_ = 0;
  109.    var _loc3_ = 1;
  110.    var _loc10_ = catchedPresent[catchedPresent.length - 1].presentType;
  111.    var _loc9_ = catchedPresent[catchedPresent.length - 2].presentType;
  112.    var _loc7_ = catchedPresent[catchedPresent.length - 3].presentType;
  113.    var _loc8_ = catchedPresent[catchedPresent.length - 4].presentType;
  114.    var _loc11_ = catchedPresent[catchedPresent.length - 5].presentType;
  115.    if(_loc10_ == _loc9_ && _loc9_ == _loc7_ && _loc7_ == _loc10_)
  116.    {
  117.       _loc4_ = true;
  118.       _loc5_ = 1;
  119.       if(_loc8_ == _loc7_)
  120.       {
  121.          _loc5_ = 2;
  122.       }
  123.       if(_loc11_ == _loc8_)
  124.       {
  125.          _loc5_ = 3;
  126.       }
  127.    }
  128.    if(_loc5_ == 0)
  129.    {
  130.       _loc3_ = 1;
  131.    }
  132.    else
  133.    {
  134.       _loc3_ = _loc5_ + 2;
  135.    }
  136.    var _loc2_ = 0;
  137.    while(_loc2_ < _loc3_)
  138.    {
  139.       var _loc1_ = catchedPresent.pop();
  140.       if(_loc1_.presentType != undefined)
  141.       {
  142.          returnMotion(_loc1_,where,_loc1_.presentType,_loc4_);
  143.       }
  144.       _loc2_ = _loc2_ + 1;
  145.    }
  146. }
  147. function returnMotion(who, where, presentType, isCombo)
  148. {
  149.    efx_extra._x = who._x;
  150.    efx_extra._y = who._y;
  151.    efx_extra.gotoAndPlay(2);
  152.    who.swapDepths(who.getDepth() + 1000);
  153.    var _loc2_ = new mx.transitions.Tween(who,"_x",mx.transitions.easing.Regular.easeOut,who._x,25 + 100 * where,0.7,true);
  154.    var _loc1_ = new mx.transitions.Tween(who,"_y",mx.transitions.easing.Regular.easeOut,who._y,400,0.7,true);
  155.    _loc1_.onMotionChanged = function()
  156.    {
  157.       who._rotation += 10;
  158.    };
  159.    _loc1_.onMotionFinished = function()
  160.    {
  161.       if(where < 5)
  162.       {
  163.          if(where == presentType + 1)
  164.          {
  165.             if(isCombo == true)
  166.             {
  167.                combo++;
  168.                efx_combo._x = 25 + 100 * where;
  169.                efx_combo._y = 320;
  170.                viewNumber(efx_combo,combo);
  171.                efx_combo.gotoAndPlay(1);
  172.             }
  173.             trace("∞╜ñδ│┤:" + combo);
  174.             score += 100 + combo * 100;
  175.             if(GAMESTATE == "GAME")
  176.             {
  177.                controll2["avt" + where].gotoAndStop(2);
  178.             }
  179.          }
  180.          else
  181.          {
  182.             combo = 0;
  183.             life -= 10;
  184.             controll.groove.gage._x = controll.groove.gage._width / 100 * life - controll.groove.gage._width;
  185.             score -= 100;
  186.             if(GAMESTATE == "GAME")
  187.             {
  188.                controll2["avt" + where].gotoAndStop(3);
  189.             }
  190.          }
  191.       }
  192.       else if(where == 5)
  193.       {
  194.          if(presentType < 4)
  195.          {
  196.             combo = 0;
  197.             life -= 10;
  198.             controll.groove.gage._x = controll.groove.gage._width / 100 * life - controll.groove.gage._width;
  199.             score -= 100;
  200.             efx.gotoAndStop(2);
  201.             efx._x = 500;
  202.             efx._y = 400;
  203.             efx.efx2.gotoAndPlay(2);
  204.          }
  205.          else
  206.          {
  207.             score += 100;
  208.             efx.gotoAndStop(1);
  209.             efx._x = 500;
  210.             efx._y = 400;
  211.             efx.efx1.gotoAndPlay(2);
  212.          }
  213.          if(GAMESTATE == "GAME")
  214.          {
  215.             controll2.avt5.gotoAndStop(2);
  216.          }
  217.       }
  218.       who.removeMovieClip();
  219.    };
  220. }
  221. function catchMiss(i)
  222. {
  223.    life -= 10;
  224.    controll.groove.gage._x = controll.groove.gage._width / 100 * life - controll.groove.gage._width;
  225.    combo = 0;
  226.    receivedPresent = -1;
  227.    if(i > 5)
  228.    {
  229.       PLAYERSTATE = "MISS";
  230.       player.gotoAndStop(3);
  231.       var _loc4_ = [-35 + player._x + random(70),player._x - 70 - random(140),player._x + 70 + random(140),player._x - 140 - random(210),player._x + 140 + random(210)];
  232.       i = 0;
  233.       while(i < 5)
  234.       {
  235.          var _loc3_ = new mx.transitions.Tween(catchedPresent[i],"_x",mx.transitions.easing.Regular.easeOut,catchedPresent[i]._x,_loc4_[i],1.5,true);
  236.          var _loc2_ = new mx.transitions.Tween(catchedPresent[i],"_y",mx.transitions.easing.Bounce.easeOut,catchedPresent[i]._y,400 - catchedPresent[i]._height,1.5,true);
  237.          _loc2_.onMotionFinished = function()
  238.          {
  239.             catchedPresent[0].removeMovieClip();
  240.             catchedPresent.shift();
  241.             PLAYERSTATE = "NORMAL";
  242.             if(GAMESTATE == "GAME")
  243.             {
  244.                player.gotoAndStop(1);
  245.             }
  246.          };
  247.          i = i + 1;
  248.       }
  249.       life -= 100;
  250.    }
  251. }
  252. function createPresent()
  253. {
  254.    var _loc3_ = random(4);
  255.    var _loc4_ = random(8);
  256.    if(createdPresent % 10 == 0 && createdPresent > 0 && _loc4_ != 4)
  257.    {
  258.       _loc4_ = 4;
  259.    }
  260.    else if(_loc4_ == 4)
  261.    {
  262.       _loc4_ = random(4);
  263.    }
  264.    this.attachMovie("note","note" + depth,100 + depth,{presentType:_loc4_,channel:_loc3_});
  265.    var _loc2_ = this["note" + depth];
  266.    _loc2_._x = 100 + 100 * _loc3_;
  267.    _loc2_.gotoAndStop(1 + _loc4_);
  268.    depth++;
  269.    if(depth > 50)
  270.    {
  271.       depth = 0;
  272.    }
  273.    _loc2_.PRESENTSTATE = "NORMAL";
  274.    _loc2_.onEnterFrame = function()
  275.    {
  276.       switch(PLAYERSTATE)
  277.       {
  278.          case "NORMAL":
  279.             if(!isPause)
  280.             {
  281.                this._y += speed;
  282.                if(this._y > 310 - catchedPresent.length * 40 - speed && this._y < 310 - catchedPresent.length * 40)
  283.                {
  284.                   if(Math.abs(this._x - player._x) < 80)
  285.                   {
  286.                      if(catchedPresent.length >= 5)
  287.                      {
  288.                         catchMiss(6);
  289.                      }
  290.                      else
  291.                      {
  292.                         catchPresent(this);
  293.                      }
  294.                   }
  295.                }
  296.                if(this._y > 350)
  297.                {
  298.                   catchMiss(0);
  299.                   this.removeMovieClip();
  300.                }
  301.             }
  302.             break;
  303.          case "MISS":
  304.             if(this.PRESENTSTATE === "NORMAL")
  305.             {
  306.                this.removeMovieClip();
  307.             }
  308.       }
  309.    };
  310.    createdPresent++;
  311.    if(createdPresent == lvuptable[Math.min(3,level - 1)])
  312.    {
  313.       level++;
  314.    }
  315. }
  316. function catchPresent(presentobj)
  317. {
  318.    receivedPresent = -1;
  319.    delete presentobj.channel;
  320.    presentobj.PRESENTSTATE = "CATCHED";
  321.    presentobj.onEnterFrame = null;
  322.    catchedPresent.push(presentobj);
  323.    presentobj.orderNumber = catchedPresent.length - 1;
  324.    score += 10 + combo * 10;
  325.    trace("llll");
  326.    presentobj.onEnterFrame = function()
  327.    {
  328.       if(PLAYERSTATE === "NORMAL")
  329.       {
  330.          if(!isPause)
  331.          {
  332.             this._x = player._x;
  333.             this._y = 350 - 40 * (this.orderNumber + 1);
  334.          }
  335.       }
  336.    };
  337. }
  338. function loopFrame()
  339. {
  340.    pauseMC._visible = isPause != true ? false : true;
  341.    if(life <= 0)
  342.    {
  343.       finalize();
  344.    }
  345.    else if(isPause == false)
  346.    {
  347.       currentTime = getTimer();
  348.       elapsedTime = currentTime - startTime;
  349.       if(elapsedTime > delay[Math.min(3,level - 1)])
  350.       {
  351.          createPresent();
  352.          startTime = getTimer();
  353.       }
  354.       if(Key.isDown(37) && PLAYERSTATE == "NORMAL")
  355.       {
  356.          keyobj.pressed = false;
  357.          player._x -= pspeed;
  358.          if(player._x < 0)
  359.          {
  360.             player._x = 0;
  361.          }
  362.          player.gotoAndStop(2);
  363.       }
  364.       else if(Key.isDown(39) && PLAYERSTATE == "NORMAL")
  365.       {
  366.          keyobj.pressed = false;
  367.          player._x += pspeed;
  368.          if(player._x > 550)
  369.          {
  370.             player._x = 550;
  371.          }
  372.          player.gotoAndStop(2);
  373.       }
  374.       else if(PLAYERSTATE == "NORMAL")
  375.       {
  376.          player.gotoAndStop(1);
  377.       }
  378.    }
  379. }
  380. var GAMESTATE = "TITLE";
  381. var PLAYERSTATE = "NORMAL";
  382. var defaultLife = 100;
  383. var life;
  384. var score = 0;
  385. var combo;
  386. var depth = 0;
  387. var speed = 10;
  388. var pspeed = 18;
  389. var level = 1;
  390. var startTime;
  391. var currentTime;
  392. var elapsedTime;
  393. var isPause = false;
  394. var isSoundon = true;
  395. var createdPresent = 0;
  396. var catchedPresent = new Array(5);
  397. var delay = [2500,2000,1500,1000,750,500];
  398. var lvuptable = [30,40,50,60,75,90];
  399. var receivedPresent;
  400. var bgm = new Sound(this);
  401. var keyobj = new Object();
  402. keyobj.pressed = false;
  403. keyobj.onKeyDown = function()
  404. {
  405.    if(keyobj.pressed == false)
  406.    {
  407.       if(Key.isDown(80) && isPause == false)
  408.       {
  409.          isPause = true;
  410.          pauseMC.gotoAndPlay(1);
  411.          startTime = getTimer();
  412.       }
  413.       else if(Key.isDown(80) && isPause == true)
  414.       {
  415.          isPause = false;
  416.          startTime = getTimer();
  417.       }
  418.       if(Key.isDown(83) && isSoundon == true)
  419.       {
  420.          isSoundon = false;
  421.          bgm.setVolume(0);
  422.       }
  423.       else if(Key.isDown(83) && isSoundon == false)
  424.       {
  425.          isSoundon = true;
  426.          bgm.setVolume(100);
  427.       }
  428.       if(Key.isDown(90) && catchedPresent.length > 0 && isPause == false)
  429.       {
  430.          returnPresent(catchedPresent[catchedPresent.length - 1],1,catchedPresent[catchedPresent.length - 1].presentType);
  431.          controll2.avt1.key.gotoAndStop(2);
  432.       }
  433.       if(Key.isDown(88) && catchedPresent.length > 0 && isPause == false)
  434.       {
  435.          returnPresent(catchedPresent[catchedPresent.length - 1],2,catchedPresent[catchedPresent.length - 1].presentType);
  436.          controll2.avt2.key.gotoAndStop(2);
  437.       }
  438.       if(Key.isDown(67) && catchedPresent.length > 0 && isPause == false)
  439.       {
  440.          returnPresent(catchedPresent[catchedPresent.length - 1],3,catchedPresent[catchedPresent.length - 1].presentType);
  441.          controll2.avt3.key.gotoAndStop(2);
  442.       }
  443.       if(Key.isDown(86) && catchedPresent.length > 0 && isPause == false)
  444.       {
  445.          returnPresent(catchedPresent[catchedPresent.length - 1],4,catchedPresent[catchedPresent.length - 1].presentType);
  446.          controll2.avt4.key.gotoAndStop(2);
  447.       }
  448.       if(Key.isDown(40) && catchedPresent.length > 0 && isPause == false)
  449.       {
  450.          returnPresent(catchedPresent[catchedPresent.length - 1],5,catchedPresent[catchedPresent.length - 1].presentType);
  451.          controll2.avt5.key.gotoAndStop(2);
  452.       }
  453.       if(Key.isDown(32) && catchedPresent.length > 0 && catchedPresent[catchedPresent.length - 1].presentType == 4 && isPause == false)
  454.       {
  455.          var _loc1_ = new Array(0,0,0,0,1,1,1,1,1,1,2,2,3,3,3,3,3);
  456.          var _loc2_ = _loc1_[random(_loc1_.length)];
  457.          switch(_loc2_)
  458.          {
  459.             case 0:
  460.                life += 10;
  461.                if(life > 100)
  462.                {
  463.                   life = 100;
  464.                }
  465.                controll.groove.gage._x = controll.groove.gage._width / 100 * life - controll.groove.gage._width;
  466.                efx.gotoAndStop(5);
  467.                efx._x = catchedPresent[catchedPresent.length - 1]._x;
  468.                efx._y = catchedPresent[catchedPresent.length - 1]._y;
  469.                efx.efx5.gotoAndPlay(2);
  470.                break;
  471.             case 1:
  472.                pspeed += 2;
  473.                if(pspeed > 26)
  474.                {
  475.                   pspeed = 26;
  476.                }
  477.                efx.gotoAndStop(4);
  478.                efx._x = catchedPresent[catchedPresent.length - 1]._x;
  479.                efx._y = catchedPresent[catchedPresent.length - 1]._y;
  480.                efx.efx4.gotoAndPlay(2);
  481.                break;
  482.             case 2:
  483.                pspeed -= 2;
  484.                if(pspeed < 8)
  485.                {
  486.                   pspeed = 8;
  487.                }
  488.                efx.gotoAndStop(7);
  489.                efx._x = catchedPresent[catchedPresent.length - 1]._x;
  490.                efx._y = catchedPresent[catchedPresent.length - 1]._y;
  491.                efx.efx7.gotoAndPlay(2);
  492.                break;
  493.             case 3:
  494.                score += 200;
  495.                efx.gotoAndStop(6);
  496.                efx._x = catchedPresent[catchedPresent.length - 1]._x;
  497.                efx._y = catchedPresent[catchedPresent.length - 1]._y;
  498.                efx.efx6.gotoAndPlay(2);
  499.          }
  500.          catchedPresent[catchedPresent.length - 1].removeMovieClip();
  501.          catchedPresent.pop();
  502.       }
  503.    }
  504.    if(!Key.isDown(37) || !Key.isDown(39))
  505.    {
  506.       keyobj.pressed = true;
  507.    }
  508. };
  509. keyobj.onKeyUp = function()
  510. {
  511.    controll2.avt1.key.gotoAndStop(1);
  512.    controll2.avt2.key.gotoAndStop(1);
  513.    controll2.avt3.key.gotoAndStop(1);
  514.    controll2.avt4.key.gotoAndStop(1);
  515.    controll2.avt5.key.gotoAndStop(1);
  516.    keyobj.pressed = false;
  517. };
  518. Key.addListener(keyobj);
  519. Array.prototype.shift2 = function(index)
  520. {
  521.    var _loc3_ = this.length;
  522.    this.splice(index,0);
  523.    var _loc2_ = index;
  524.    while(_loc2_ < _loc3_)
  525.    {
  526.       this[_loc2_] = this[_loc2_ + 1];
  527.       _loc2_ = _loc2_ + 1;
  528.    }
  529.    this.pop();
  530. };
  531.